﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Web;
using System.Web.Mvc;
using Prodma.DataAccess.Models.ViewModels;
using Prodma.DataAccess.Models.UserControlViewModels;

namespace Prodma.DataAccess.Authorization
{
    public class Authorization
    {

        #region Get Navigation
        public static NavigationVm GetNavigation(string view, int id)
        {
            RoleVm authorization = (RoleVm)HttpContext.Current.Session["userAuthorization"];


            if (authorization == null)
            {
                return new NavigationVm();
            }

            NavigationVm navigation = new NavigationVm();
            navigation.View = view;


            if (navigation.View == "urunler")
            {
                if (authorization.ClearChart == true)
                {
                    navigation.ClearChart = true;
                }
                if (authorization.Search == true)
                {
                    navigation.Search = true;
                }
            }

            if (navigation.View == "sepet")
            {
                if (authorization.ClearChart == true)
                {
                    navigation.ClearChart = true;
                }

                if (authorization.AmendOrder == true)
                {
                    navigation.AmendOrder = true;
                }

                if (authorization.ConfirmOrder == true)
                {
                    navigation.ConfirmOrder = true;
                }
            }

            if (navigation.View == "onayla") {
                if (authorization.CompleteOrder == true)
                {
                    navigation.CompleteOrder = true;
                }
            
            }

            return navigation;
        }
        public static NavigationVm GetNavigation(string view, int id, List<string> keys, List<string> values)
        {
            RoleVm authorization = (RoleVm)HttpContext.Current.Session["userAuthorization"];

            if (authorization == null)
            {
                return new NavigationVm();
            }

            NavigationVm navigation = new NavigationVm();
            navigation.View = view;
            navigation.Keys = keys;
            navigation.Values = values;


            if (navigation.View == "urunler")
            {
                if (authorization.AddChart == true)
                {
                    navigation.AddChart = true;
                }
                if (authorization.Search == true)
                {
                    navigation.Search = true;
                }
            }

            if (navigation.View == "sepet")
            {
                if (authorization.AmendOrder == true)
                {
                    navigation.AmendOrder = true;
                }

                if (authorization.ConfirmOrder == true)
                {
                    navigation.ConfirmOrder = true;
                }
            }

            if (navigation.View == "onayla")
            {
                if (authorization.CompleteOrder == true)
                {
                    navigation.CompleteOrder = true;
                }

            }
            return navigation;
        }
        #endregion

    }
}

